package com.beself.controller;

import com.beself.service.HabitService;
import com.beself.until.RestJson;
import org.apache.taglibs.standard.tag.common.xml.IfTag;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/api/habit")
public class HabitController {

    @Resource
    private RestJson restJson;

    @Resource
    private HabitService habitService;

    @RequestMapping("/insert")
    @ResponseBody
    public RestJson insertHabit(String habitName){

      Boolean flag =   habitService.insertHabit(habitName);
        if(flag){
            restJson = new RestJson(true,"成功",null);
        } else {
            restJson = new RestJson(false,"失败",null);
        }
        return restJson;
    }


}